#列表
arr = []
arr = list()
arr = list('a')
arr = list(range(2, 11))
arr = ['hello', 1, True, 3.14, 2 + 3j, print, sum]
arr = [0] * 10
arr = [i * 2 for i in range(100) if i % 3 == 0]
lst = [1, 2, 3, 4, 5, 6]
arr = [i + 2 for i in lst]
# arr = list(map(int, input()))
# arr = [int(i) for i in input()]
arr = [1, 2, 3, 4, 5, 6]
# print(arr[-1])
# print(arr[-len(arr)])
# print(arr[-2])
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
# print(arr[::])
# print(arr[2:len(arr):2])
# print(arr[::-1])
# print(arr[2:-2:1])
# print(arr[-2:2:-1])
# arr = [1, 2, 3]
# arr2 = [4, 5, 6]
# print(arr + arr2)
# arr3 = arr * 5
# print(arr3)
# sum = max
# print(sum(5, 6, 7, 8))
#列表对象函数
arr = [1, 2, 3]
# arr.append(5)
# arr.insert(1, 10)
# # print(arr.index(3))
# arr.insert(100,50)
# arr.insert(-50, 60)
# print(arr)
arr1 = [1, 2, 3]
arr2 = [4, 5, 6]
# arr1.extend(arr2)
# arr1.append(arr2)
# print(len(arr1))
# print(arr1)
# arr = [3, 2, 1, 3, 2, 1]
# arr.remove(3)
# print(arr)
# arr.remove(100)
# arr = [1, 2, 3, 4, 5, 6]
# print(arr.pop(0))
# print(arr)
# arr = [1, 2, 3, 4, 5, 6]
# del arr[::2]
# print(arr)
arr = [2, 8, 4, 3, 9, 7, 1, 5 ,6 ,8, 1, 0, 54, 98 ,62 ,3, 11]
# print(arr)
# arr.sort()
# print(arr)
# arr.sort(reverse=True)
# print(arr)
# arr = ["banana", "apple","cat","dog","elephant","fruit","girlfreind"]
# arr.sort(key=len)
# print(arr)
# 
# arr.reverse()
# print(arr)
# arr = [1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1]
# print(arr.count(1))
# print(arr.count(0))
# print(len(arr))
# arr.clear()
# print(arr)
# arr1 = [1, 2, 3, 4, 5 ,6]
# arr2 = arr1
# arr1[0] = 666
# print(arr2)
# print(arr1)
# arr1 = [1, 2, 3, 4, 5 ,6]
# arr2 = arr1.copy()
# arr1[0] = 666
# print(arr1)
# print(arr2)
#列表相关操作
# arr = [1, 2, 3, 4, 5, 6]
# for index in range(len(arr)):
#     arr[index] = arr[index] + 1
# print(arr)
# for element in arr:
#     print(element, end = " ")
# for index, element in enumerate(arr):
#     print(f'arr[{index}]={element}')
#寻找最值
# def min_max(arr):
#     min_value = arr[0]
#     max_value = arr[0]
#     for element in arr:
#         if element > max_value:
#             max_value = element
#         if element < min_value:
#             min_value = element
#     return min_value, max_value
# arr = [2,9,8,1,7,4,6,3,5]
# min_val, max_val = min_max(arr)
# print(min_val, max_val)
#存在性
# arr = [2,9,8,1,7,4,6,3,5]

# def is_exist(arr:list[int], key:int) ->bool:
#     for element in arr:
#         if key == element:
#             return True
#     return False
# print(is_exist(arr, 100))
# print(is_exist(arr, 2))
#反转
# def lst_reverse(arr:list[int])->None:
#     left = 0
#     right = len(arr) - 1
#     for index in arr:
#         arr[left], arr[right] = arr[right], arr[left]
#         left += 1
#         right -= 1
#         if left >= right:
#             break


# arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# lst_reverse(arr)
# print(arr)
#乱序
# import random
# def lst_shuffle(arr:list[int])->None:
#     for index in range(len(arr)):
#         shu = random.randint(0, len(arr) - 1)
#         arr[index], arr[shu] = arr[shu], arr[index]


# arr = [1, 2, 3, 4, 5, 6, 7, 8 ,9, 10]
# lst_shuffle(arr)
# print(arr)

#二位列表
#打印二维列表
def print_matrix(matrix)->None:
    for i in range(len(matrix)):
        for element in matrix[i]:
            print(element, end = " ")
        # for j in range(len(matrix[i])):
        #     print(matrix[i][j], end = " ")
        print()

# matrix = [[1,2, 3], [4, 5, 6], [7, 8, 9]]
# print(matrix)
# print(len(matrix))
# print(len(matrix[1]))
matrix = [
    [1,2,3,4],
    [1,2,3],
    [1,2],
    [1]
]
# print_matrix(matrix)
#循环创建二维列表
rows = 3
cols = 5
for i in range(rows):
    row = [0] * cols
    matrix.append(row)
# print_matrix(matrix)
matrix = [[0] * cols for i in range(rows)]
matrix[2][4] = 6
# print_matrix(matrix)
matrix = [[i + j for j in range(cols)] for i in range(rows)]
print_matrix(matrix)